#include "Csdl.h"

Csdl::Csdl(bool init_ttf,bool init_mixer)
{
	SDL_Surface * screensurface=NULL;


	SDL_Init(SDL_INIT_EVERYTHING);
	if(init_ttf)
	{
		ttf=true;
		TTF_Init();

	}

	if(init_mixer)
	{
		mixer=true;
		Mix_OpenAudio( 22050, MIX_DEFAULT_FORMAT, 2, 4096 );
		Mix_AllocateChannels(16);

	}


}

Csdl::~Csdl()
{
	if(ttf)TTF_Quit();
	if(mixer)Mix_CloseAudio();
	SDL_Quit();
}

void Csdl::SetVideoMode( int width, int height, bool fullscreen=false, int bpp=32,std::string caption="NoName")
{

	if(fullscreen)screensurface=SDL_SetVideoMode(width,height,bpp,SDL_FULLSCREEN | SDL_SWSURFACE);
	else screensurface=SDL_SetVideoMode(width,height,bpp,SDL_SWSURFACE);
	
	SDL_WM_SetCaption(caption.c_str(),NULL);
	
	

}


void Csdl::ScreenRefresh()
{
	SDL_Flip(screensurface);
}

void Csdl::ChangeCaption(std::string capt)
{
SDL_WM_SetCaption(capt.c_str(),NULL);
}

std::string Csdl::IntToString(int number)
{
		std::stringstream MyString;
		MyString << number;
		return MyString.str();



}